package cn.richx.pushmessage.message;

import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author caohao
 * @date 2018-04-23
 */
public class PushItem implements Serializable {


    /**
     * 0系统预留，1校园公告，2在线请假(Type:2 pushContentType:1请假审批通知  2请假审批通过通知 3请假审批拒绝通知 )，
     * 3会议通知，4宿舍通知，5校车通知，
     * 6短信平台 (Type:6 pushContentType:1教师通知  2学生通知)
     * 7成绩通知，8进出校园,
     * 9一卡通， 10 一体机接送通知， 11 晨检 , 12 作息时间设置 ，13幼儿园版老师评价， 14 食谱变动， 15作业发布
     * 16 新闻、活动、招生信息发布
     * 17支付(pushContentType:1支付成功 2支付失败 3转账成功 4短信购买成功 5短信购买失败 6短信代购付款成功 7短信代购付款失败 8补办卡费用支付成功 9补办卡费用支付失败 )
     * 18提现(pushContentType:1提现成功 2提现申请 3：拒绝提现)
     * 19补卡通知(pushContentType:1补办卡退款)
     * 20服务费订购通知(pushContentType:1 订购通知 ) 备注：提醒用户购买
     * 21资产维修通知(pushContentType:1 资产报修通知,2资产催单通知,3资产审核通知,4资产审核通过通知,5资产审核不通过通知,6资产维修完成通知 )
     * 22安全隐患排查(pushContentType:1 上传安全隐患排查通知 )
     * 50新闻资讯,
     * 51好友通知(pushContentType:1.申请好友,2.同意添加好友 3.拒绝添加好友 4.删除好友)
     * 52群组通知(pushContentType:1.申请加为群组成员,2.群管理员同意添加,3.群管理员拒绝添加,4.邀请加为群成员,5.
     * 被邀请人同意加入,6.被邀请人拒绝加入,7.解散群组,8.删除群组成员,9.设置群管理员,10.退出群组)
     * 53关联通知(pushContentType:1.申请关联,2.同意关联 3.拒绝关联 4.删除关联)
     * 说明：新增类型时请在palm_information_type中手动增加一条对应的数据  用于设置对应的信息提醒类型
     * 54无障碍通道(pushContentType:1.接送申请,2接送申请通过通知,3接送申请拒绝通知,4拜访邀请,5回复拜访邀请,6拜访邀请拒绝通知,7.家长进出通知)
     * 55留言平台，(Type:55 pushContentType:1教师通知  2学生通知)
     * <p>
     * =========================================
     * =====目前pushType （80 - 95） 是 OA申请使用=====
     * =========================================
     * 80宿舍申请(pushContentType:1.申请,2.审核结束通知 ,3.驳回通知)
     * 81功能室申请(pushContentType:1.申请,2.审核结束通知)
     * <p>
     * <p>
     * 83固定资产申请领用(pushContentType:1等待审核,2审核通过,3驳回,4退回修改)
     * 84 固定资产申请维修(pushContentType:1等待审核,2审核通过,3驳回,4退回修改)
     * 85 固定资产申请归还(pushContentType:1等待审核,2审核通过,3驳回,4退回修改)
     * 86 固定资产申请报废(pushContentType:1等待审核,2审核通过,3驳回,4退回修改)
     * 87 固定资产申请购买(pushContentType:1等待审核,2审核通过,3驳回,4退回修改)
     * 88 耗材申请领用(pushContentType:1等待审核,2审核通过,3驳回,4退回修改)
     */
    private int PushType;
    private int PushContentType;
    private String PushContent;

    /*** 推送人头像（申请加入群：推送人头像,邀请加入群：群头像） ***/
    private String PushImage;
    /*** 推送人id ***/
    private int PushSenderId;
    /*** 推送人名字 ***/
    private String PushSender;
    /*** 推送人容联云账号 ***/
    private String PushSenderVoipAccount;


    /*** 群id ***/
    private int PushGroupId;
    /*** 群名字 ***/
    private String PushGroupName;

    private String PushUrl;
    private String CreateTime;
    /*** 申请记录id ***/
    private String OperationapplyId;
    /*** OA申请记录id ***/
    private String OAApplyId;
    /*** 标题 ***/
    private String title;
    /*** 渠道 ***/
    private String channels;
    /*** 设备类型 3：android 4 ：ios ***/
    private String deviceType;
    /*** 推送接收人id ***/
    private int receiverId;
    private HashMap<String, Object> aps;
    private String PushData;
    /*** 后台pushmessage的主键 ***/
    private int pushId;
    /*** 消息接受者id,手机端需要使用,当前用户的userid ***/
    private int PushOwnerID;
    /*** 接收到推送通知之后的操作结果,手机端需要使用,0：拒绝,1：通过,2:未操作 ***/
    private int OperationResult;

    private String schoolId;

    public int getPushType() {
        return PushType;
    }

    public void setPushType(int pushType) {
        PushType = pushType;
    }

    public int getPushContentType() {
        return PushContentType;
    }

    public void setPushContentType(int pushContentType) {
        PushContentType = pushContentType;
    }

    public String getPushContent() {
        return PushContent;
    }

    public void setPushContent(String pushContent) {
        PushContent = pushContent;
    }

    public String getPushImage() {
        return PushImage;
    }

    public void setPushImage(String pushImage) {
        PushImage = pushImage;
    }

    public int getPushSenderId() {
        return PushSenderId;
    }

    public void setPushSenderId(int pushSenderId) {
        PushSenderId = pushSenderId;
    }

    public String getPushSender() {
        return PushSender;
    }

    public void setPushSender(String pushSender) {
        PushSender = pushSender;
    }

    public String getPushSenderVoipAccount() {
        return PushSenderVoipAccount;
    }

    public void setPushSenderVoipAccount(String pushSenderVoipAccount) {
        PushSenderVoipAccount = pushSenderVoipAccount;
    }

    public int getPushGroupId() {
        return PushGroupId;
    }

    public void setPushGroupId(int pushGroupId) {
        PushGroupId = pushGroupId;
    }

    public String getPushGroupName() {
        return PushGroupName;
    }

    public void setPushGroupName(String pushGroupName) {
        PushGroupName = pushGroupName;
    }

    public String getPushUrl() {
        return PushUrl;
    }

    public void setPushUrl(String pushUrl) {
        PushUrl = pushUrl;
    }

    public String getCreateTime() {
        return CreateTime;
    }

    public void setCreateTime(String createTime) {
        CreateTime = createTime;
    }

    public String getOperationapplyId() {
        return OperationapplyId;
    }

    public void setOperationapplyId(String operationapplyId) {
        OperationapplyId = operationapplyId;
    }

    public String getOAApplyId() {
        return OAApplyId;
    }

    public void setOAApplyId(String OAApplyId) {
        this.OAApplyId = OAApplyId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getChannels() {
        return channels;
    }

    public void setChannels(String channels) {
        this.channels = channels;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public int getReceiverId() {
        return receiverId;
    }

    public void setReceiverId(int receiverId) {
        this.receiverId = receiverId;
    }

    public HashMap<String, Object> getAps() {
        return aps;
    }

    public void setAps(HashMap<String, Object> aps) {
        this.aps = aps;
    }

    public String getPushData() {
        return PushData;
    }

    public void setPushData(String pushData) {
        PushData = pushData;
    }

    public int getPushId() {
        return pushId;
    }

    public void setPushId(int pushId) {
        this.pushId = pushId;
    }

    public int getPushOwnerID() {
        return PushOwnerID;
    }

    public void setPushOwnerID(int pushOwnerID) {
        PushOwnerID = pushOwnerID;
    }

    public int getOperationResult() {
        return OperationResult;
    }

    public void setOperationResult(int operationResult) {
        OperationResult = operationResult;
    }

    public String getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(String schoolId) {
        this.schoolId = schoolId;
    }

    public Map<String, Object> convertMsgMap(String appName) {
        Map<String, Object> msg = new HashMap<String, Object>();

        msg.put("title", this.title);
        String description = StringUtils.isNotBlank(this.PushContent) ?
            (this.PushContent.length() > 60 ? this.PushContent.substring(0, 60) + "..." : this.PushContent)
            : appName + "向您发送了一条新消息，请注意查收";
        msg.put("description", description);
        msg.put("notification_builder_id", 0);
        msg.put("notification_basic_style", 4);
        msg.put("open_type", 3);
        msg.put("custom_content", JSONObject.fromObject(this).toString());

        return msg;
    }
}
